home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / BBS / MUBBS / E-Mail 1.5 source.cpt / E-mail / CheckForEmail.c < prev    next >
Text File  |  1992-01-03  |  7KB  |  267 lines

  1. /* *********************************************************************************
  2.      
  3.       MODULE:        CheckForEmail Module
  4.       
  5.      DESCRIPTION:    This CheckForEmail Module is a simple module for MUBBS, the
  6.                      Multi-User Bulliten Board System Software.
  7.                      
  8.      AUTHOR:        Noam Freedman
  9.      
  10.      Copyright © 1990 by Noam Freedman. Portions are also Copyright Symantec Corp.
  11.  
  12.      This program source code and it's compiled version IS NOT IN THE
  13.      PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NMF" file for details
  14.      regarding use of this program source code and it's compiled version.
  15.      
  16.      Revision History:
  17.      ============================================================
  18.      10/20/91 - Started programming
  19.      11/ 4/91 - Edited for release
  20.      ============================================================
  21.      
  22.  
  23.     ******************************************************************************** */
  24.  
  25.  
  26. #define        INMAIN
  27.  
  28.  
  29. #include    "MUBBS Module.h"
  30. #include    <SetUpA4.h>
  31. #include    "Email.h"
  32.  
  33. /* my globals for this module */
  34.  
  35.  
  36.  
  37. pascal void main (mode1,G1,P1) /* called from the main routines, and what mode to be in */
  38. int mode1;
  39. struct GS *G1; /* we point to the "global" struct in the Main Module here */
  40. Ptr P1; /* we ignore this pointer, we do not use it at all */
  41. {
  42. Handle temph;
  43. float version = 0.5; /* what version of MUBBS you are compatable with IE: .5 and above */
  44. RememberA0(); SetUpA4(); /* This sets up the A4 register to access our globals */
  45. asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* locks our module, do this ! */
  46.  
  47. G=G1; /* This MUST be the first thing you do in main only, it sets up the struct globals */
  48. mode[u]=mode1; /* set up our mode so that you can read it anywhere */
  49.  
  50. switch (mode[u]) { /* any un-handled modes return error from this module */
  51.     case 2:
  52.         dostuff();
  53.         G->moduleresult=0;
  54.         break;
  55.     case 98:
  56.         versionck(version); /* just return after this call, don't modify anything */
  57.         break;        
  58.     case 0:
  59.         strcpy (G->programmer,"Noam Freedman"); /* show the programmer's name up to 20 chars*/
  60.         G->moduleresult=0; /* this was also a init call if we need close call put 99 here */
  61.         break;
  62.     default:
  63.         G->moduleresult=1; /* return bad code */
  64.     };
  65.  
  66. HUnlock(temph); /* unlocks this module, do this ! */
  67. RestoreA4(); /* call this when you are all done */
  68. }
  69.  
  70.  
  71.  
  72. dostuff()
  73. {
  74. int choice, i, num, r, deleteflag;
  75. char tempstring[10], ch;
  76. struct LoadStruct S;
  77. struct MsgStruct MsgInfo;
  78. struct EnterStruct E;
  79. FILE *fp_headers;
  80.  
  81. if (!G->online[u]) { num = 2;goto byebye; } /* do this check so we can log out if hang up */
  82.  
  83. loguser("In E-Mail Module"); /* this tells where you are for remote sysop, or writes to log file */
  84.  
  85. /* you print the following so that the sysop can monitor use on the mac screen */
  86.  
  87. print("C> Line %d %s, at: E-Mail\n",(u+1),G->username[u]);
  88.  
  89. while (TRUE)
  90.     {
  91.     if(!cmd1("]]   *** E-Mail Menu ***]]>> Read, Send, Help, Quit : ")) goto byebye;
  92.     send(G->CR[u]);
  93.     ch = G->input[u];
  94.     switch(ch)
  95.         {
  96.         case 'H':
  97.                 send("]E-Mail Menu:");
  98.                 send("]");
  99.                 send("]     This the main E-Mail menu, you select if you want to read");
  100.                 send("]or send some mail to another person. To delete a message, read it first:");
  101.                 send("]");
  102.                 send("]R)ead     - Checks for any existing mail and allows you to read it.");
  103.                 send("]");
  104.                 send("]S)end     - Allows you to send mail to another user.");
  105.                 send("]");
  106.                 send("]H)elp     - Displays this file.");
  107.                 send("]");
  108.                 send("]Q)uit     - Leaves E-Mail.");
  109.                 send("]");
  110.                 break;                            
  111.         case 'R':
  112.                 goto CheckEmail;
  113.                 break;                    
  114.         case 'S':
  115.                 goto SendEmail;
  116.                 break;
  117.         case 'Q':
  118.                 goto byebye;
  119.                 break;
  120.                             
  121.  
  122.         }
  123.  
  124. continue; /* back to start of while */
  125.  
  126. CheckEmail:
  127.  
  128. module (3,"check_email",&S);
  129.  
  130. if (S.result == 20)
  131.     {
  132.     send("]You have %i or more pieces of mail.  To view MORE you must delete some.]",MAXEMAIL);
  133.     }
  134. if (S.result == 21)
  135.     {
  136.     send("]You have no mail at this time.]");
  137.     continue;
  138.     }
  139.  
  140. if (S.result != 0) continue;
  141.  
  142. AskQuestion: /* this is default (S.result = 0) */
  143.  
  144. r = 0;
  145.  
  146. send("]You have mail from:]]");                
  147.  
  148. for ( i=1 ; i<=S.numemail ; i++)
  149.     {
  150.     send("%i)  %s   %s]",i,S.FromUser[i],S.title[i]);
  151.     }
  152. send("]>> # to read, (return=first), Quit : ");
  153. portsin(tempstring, 2);
  154. send(G->CR[u]);
  155. if (! G->online[u]) goto byebye;
  156. if (tempstring[0] == 'Q') continue; /* go back to main menu */
  157. if (tempstring[0] == 'q') continue;
  158. S.choice=strtoint(tempstring,"%i",&S.choice);
  159. if ( S.choice == 0) S.choice=1;
  160. if ( S.choice > S.numemail ) {
  161.     send("]Invalid choice, please try again.]]");
  162.     goto AskQuestion;
  163.     }
  164.     
  165. send(G->CR[u]);
  166.  
  167. DisplayMessage:
  168. module(3,"display_email",&S);
  169.  
  170. send ("]-END-");
  171. if (S.choice == 1) send ("   (Please delete your mail when you are done with it)]");
  172. else send(G->CR[u]);
  173. back:
  174.     if(!cmd1("]>> Email sender, Delete, Re-read, + (return), -, Help, Quit : ")) goto byebye;
  175.     send(G->CR[u]);
  176.     ch = G->input[u];
  177.     switch(ch)
  178.         {
  179.         case 'H':
  180.                 send("]E-Mail Prompt:");
  181.                 send("]");
  182.                 send("]     The E-mail prompt is shown after a e-mail message has been");
  183.                 send("]shown. There are 8 option to choose from:");
  184.                 send("]");
  185.                 send("]E)mail sender  - Begins an e-mail message addressed to the");
  186.                 send("]                 person who sent you the last message you read.");
  187.                 send("]");
  188.                 send("]D)elete        - Deletes the current e-mail message.");
  189.                 send("]");
  190.                 send("]R)e-read       - Displays the last e-mail message again.");
  191.                 send("]");
  192.                 send("]+              - Advances to the next e-mail message (or hit RETURN).");
  193.                 send("]");
  194.                 send("]-              - Retreats to the previous e-mail message.");
  195.                 send("]");
  196.                 send("]H)elp          - Displays this file.");
  197.                 send("]");
  198.                 send("]Q)uit          - Returns to E-Mail Main Menu.");
  199.                 send("]");
  200.                 break;                            
  201.         case 'R':
  202.                 goto DisplayMessage;
  203.                 break;
  204.                             
  205.         case 'E':
  206.                 if (!cmd1("]Delete this message first (Y/N) (return=YES) ? ") )  return;
  207.                 send(G->CR[u]);
  208.                 deleteflag=FALSE;
  209.                 if (G->input[u] != 'N')
  210.                     {
  211.                     module(3,"delete_email",&S); /* delete it */
  212.                     deleteflag=TRUE;
  213.                     }
  214.                 strcpy(E.ToUser,S.FromUser[S.choice]); /* set this to the sender's name */
  215.                 module(3,"enter_email",&E); /* call the enter module */
  216.                 if (E.result ==10) module(3,"save_email",&E); /* call the save module */
  217.                 if (deleteflag) {
  218.                     module (3,"check_email",&S); /* do the check again */
  219.                     if (S.result == 21) continue; /* no more mail */
  220.                     if (S.result != 0) continue; /* or fall through to + */
  221.                     }
  222.                 goto fall;
  223.                 break;
  224.         case 'Q':
  225.                 continue;                            
  226.                             
  227.         case '-':
  228.                 if (S.choice <= 1)
  229.                     S.choice = S.numemail;
  230.                 else
  231.                     S.choice = S.choice - 1;
  232.                 goto DisplayMessage;
  233.                 break;
  234.  
  235.         case 'D':
  236.                 module(3,"delete_email",&S); /* delete it */
  237.                 module (3,"check_email",&S); /* do the check again */
  238.  
  239.                 if (S.result == 21) continue; /* no more mail */
  240.                 if (S.result != 0) continue; /* or fall through to + */
  241.         case '+':
  242.         case '\r':
  243.         
  244.         fall:
  245.                 if (S.choice >= S.numemail)
  246.                     S.choice = 1;
  247.                 else
  248.                     S.choice = S.choice + 1;
  249.                 goto DisplayMessage;
  250.                 break;
  251.         }
  252. goto back;
  253.  
  254.     
  255. SendEmail:
  256.  
  257. strcpy(E.ToUser,""); /* set this to blank so it asks for a user's name */
  258. module(3,"enter_email",&E); /* call the enter module */
  259. if (E.result == 10) module(3,"save_email",&E); /* call the save module */
  260.  
  261.  
  262. } /* closes "main menu" while loop */
  263.  
  264. byebye:
  265. return;
  266. }
  267.